﻿<!DOCTYPE html>
<html>
<#include "../../include/resource.html">
<body>
	<#assign nid="shop"> 
	<#include "../../common/function.html"> 
	<#include "../../include/header.html">
	<link href="${request.getContextPath()}/media/css/modal.css" rel="stylesheet" type="text/css" />
	<!-- #main start-->
	<div id="main" class="clearfix" style="border-top:1px solid #ccc" >
		<!-- .wrap950 开始-->
		<div class="wrap950 ">
			<!--左边的导航user_left 开始-->
			<!--  V1.6.7.1 zhangyz 2013-11-20 start -->
			<div class="user_left">
				<#assign mid="m_shop" >
				<#include "../user_menu.html">
			</div>
			 <!--  V1.6.7.1 zhangyz 2013-11-20 end -->
			<!--左边的导航user_left 结束-->

			<!--右边的内容user_right 开始-->
			<div class="shop_main">
			
				<#if errormsg?exists && errormsg != "">
					<div id="msg25">
						<p class="error"> ${errormsg} </p>
					</div>
				<#elseif msg?exists && msg != "">
					<div id="msg24">
						<p class="ok"> ${msg} </p>
					</div>
				</#if>
				<style>
					.shop_main .user_right_border{ width:45%; float:left;}
				</style>
				<!--右边的内容user_right_main 开始-->
				<div class="user_right_main clearfix">
					<p class="text_dh">
						3000积分兑换一年VIP，并且一年只能兑换一次。积分兑换VIP以后，减去相应的积分分值。
					</p>
					<!-- 内容开始 -->
					<form action="${webroot}/credit/cashVip.html" method="post" onSubmit="return check_form()" name="form1">
			<div class="user_right_border">
				<div class="l" style="font-weight:bold;">真实姓名：</div>
				<div class="c">
					${session_user.realname}		
				</div>
			</div>
		
			<div class="user_right_border">
				<div class="l" style="font-weight:bold;">总积分：</div>
				<div class="c">
					${(credit.value)!0}
				</div>
			</div>
		
			<div class="user_right_border">
				<div class="l" style="font-weight:bold;">消费积分：</div>
				<div class="c">
					${(credit.expense_value)!0}
				</div>
			</div>
		
			<div class="user_right_border">
				<div class="l" style="font-weight:bold;">可用积分：</div>
				<div class="c"><#if credit?? && credit.valid_value??><input type="hidden" value="${credit.valid_value?c!0}" id="valid_value"></#if>
					${(credit.valid_value)!0}
				</div>
			</div>
			
			<div class="user_right_border" style=" width:100%;">
				<div class="l" style="font-weight:bold;">兑换备注：</div>
				<div class="c">
						<textarea rows="6" cols="70" type="text" name="creditConvert.remark" maxLength="255"/></textarea>
				</div>
			</div>
		
			<div class="user_right_border" style=" width:100%;">
				<div class="l" style="font-weight:bold;">兑换VIP积分：</div>
				<div class="c">
					<input type="hidden" id="credit_value"  name="creditConvert.credit_value" value="${integral?c}"/>${integral?c}<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<#if result?? && result == false>您暂时不能申请兑换VIP操作。</#if><font color="#FF0000" id="real_remark"></font></span>
				</div>
			</div>

			<div class="user_right_border">
				<div class="l" style="font-weight:bold;"></div>
				<div class="c">
				<#if credit_cash_token?exists && credit_cash_token != "">
					<input type="hidden" name="credit_cash_token" value="${credit_cash_token}" />
					</#if>
					<#if result?? && result == true>
					<input type="submit" class="btn-action"  name="name"  value="确认提交" size="30" /> 
					</#if>
				</div>
			</div>
		</form>
					<!-- 内容结束 -->
				</div>
				<!--右边的内容user_right_main 结束-->
			</div>
			<!--右边的内容user_right 结束-->
		</div>
		<!-- .wrap950 结束-->
	</div>
	<!-- #main start-->
	<script>
	 function check_form(){
		var value = $("#credit_value").val();// 兑换积分
		var valid_value = $("#valid_value").val();// 有效积分
   	 	var credit_value = parseInt(value);
   	 	var numReg =  /^[0-9]$|^[1-9][0-9]+$/;  
	   	if(credit_value != null && credit_value > 0 && credit_value <= valid_value && numReg.test(value)){
	   		 return true;
	    }else{
	    	if(credit_value > valid_value){
	    		$("#credit_value").val(0);
				document.getElementById('real_remark').innerHTML = "您的有效积分不足，不能兑换VIP。";
	    	}
			return false;
	    }
	}
     
	</script>
	<#include "../../include/footer.html">